'''
@ version: Python3.8
@ Project: Selenium
@ FileName:verify_name.py
@ Date:    2023/3/1 13:59
@ Author:  jjia
@ Desc:
'''
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium import webdriver
from time import sleep

option = webdriver.ChromeOptions()
# 屏蔽V76以上自动化受控提示 ，开发者提示
option.add_experimental_option('useAutomationExtension', False)
option.add_experimental_option("excludeSwitches", ['enable-automation'])

# 不自动关闭浏览器
option.add_experimental_option('detach', True)
driver = webdriver.Chrome(options=option)


def open_site():
    url = 'https://b.alipay.com/page/product-mall/product-detail/I1080300001000046143?' \
          'chInfo=ch_zhfbzhzh-pc-0825_zhifubaoshangjiazhifupingtai'
    driver.get(url)
    sleep(4)
    driver.maximize_window()
    sleep(1)


def verify():
    # ActionChains(dr).move_by_offset(200, 100).click().perform()  # 鼠标左键点击， 200为x坐标， 100为y坐标
    # ActionChains(dr).move_by_offset(200, 100).context_click().perform()  # 鼠标右键点击
    driver.find_element(By.XPATH, '//div/a[@class="login___1wfoZ"]').click()
    # driver.find_element(By.CLASS_NAME, 'login___1wfoZ').click()
    sleep(5)
    # 切换到登录frame
    driver.switch_to.frame('__login_frame')

    # driver.find_element(By.NAME, 'logonId').send_keys('170****1681')
    # sleep(1)
    # driver.find_element(By.NAME, 'password_rsainput').send_keys('xsrs1234zfb')
    # sleep(1)
    # driver.find_element(By.XPATH, '//*[@id="J-login-btn"]').click()
    # sleep(1)

    driver.find_element(By.ID, 'J-qrcode-target').click()
    sleep(10)
    #  返回主页面
    driver.switch_to.default_content()
    # 点击转账
    driver.find_element(By.XPATH, '//div/a[@href="https://bizfundprod.alipay.com/payment'
                                  '/transfer/index.htm#/?_k=2y6iu4"]/span').click()
    sleep(2)

    # 输入手机号
    driver.find_element(By.ID, 'ipt-search-key').send_keys('188****5170')
    text = driver.find_element(By.ID, 'ipt-search-key').get_attribute('')
    print('查询内容是', text)


if __name__ == '__main__':
    open_site()
    verify()